package com.tiwi.gmbdr;

import com.tiwi.gmbdr.OpenHelper.UserOpenHelper;
import com.tiwi.gmbdr.model.User;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;



public class NewProfileActivity extends Activity implements OnClickListener{
	TextView textview;
	EditText namaProfile;
//	private Activity activity; => tidak perlu didefinisi..cukup pakai this saja.. karena class ini extends Activity maka this=Activity
	private Button save_button;
	User bean ;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.new_profile_activity);
		
	
		textview = (TextView) this.findViewById(R.id.textView1);
		namaProfile = (EditText) this.findViewById(R.id.editText1); 
		save_button =  (Button) this.findViewById(R.id.button1);
		save_button.setOnClickListener(this);

	}

	@Override
	public void onClick(View v) {
		UserOpenHelper userOpenHelper = new UserOpenHelper(this);// ganti dengan this.. tadinya activity, padahal activity belum ada isinya (null) makanya jadi force close
		// TODO Auto-generated method stub
		if(v.getId()==R.id.button1){
			bean = new User(namaProfile.getText().toString(),1,0);
			userOpenHelper.insertUser(bean);
		}
		
	}

	
	
}
